#e
#Title[uubNЂɋ΂߂Ă񂾂A͌EȂv]
#Text[]
#Image[]
#BackGround[]
#BGM[]
#PlayLevel[Extra]
#ScriptVersion[2]
#Player[FREE]

script_enemy_main
{
let wt=80;
let usebomb=0;

	//GoɈxs镔
	@Initialize
	{
	//   eϐ

	//   XyJ[hf[^
	SetLife(800);
	SetScore(200000);
	SetDamageRate(60,  0);
	SetTimer(40);
	SetInvincibility(250);
	SetEffectForZeroLife(1200,60,0);
	LoadGraphic("script\img\ExRumia.png");
	CutIn(KOUMA,"ubNЂɋ΂߂Ă񂾂A͌EȂ",GetCurrentScriptDirectory~"..\img\cutin08.png",0,0,255,320);

	}
	//   ʒu܂ňړ
	SetMovePosition02(GetCenterX, GetClipMinY+80, 60);

	BG_Standard;
	AtackTask;
	//ControlTask;
	//G̃Ct0ɂȂ܂ŁA̕1t[1s
	@MainLoop
	{
		yield;


		if(OnBomb==false){
			SetCollisionA(GetX, GetY, 32);
			SetCollisionB(GetX, GetY, 24);
			usebomb=0;
		}
		else{
			usebomb++;
		}
		if(usebomb==1){
			BombBarrier;
		}
	}
	
	//`惋[vB1t[1s
	@DrawLoop
	{
		SetGraphicRect(64,1,127,64);
		if(GetSpeedX<0){
			SetGraphicRect(128,1,191,64);
		}
		if(GetSpeedX>0){
			SetGraphicRect(192,1,255,64);
		}
		SetColor(255,255,255);
		SetAlpha(255);
		if(OnBomb==true){SetAlpha(96);}
		SetTexture("script\img\ExRumia.png");//摜͔q
		DrawGraphic(GetX(),GetY());//G̍WEx[~A`;
	}
		
	//GłuԂɈxs镔
	@Finalize
	{
		DeleteGraphic("script\img\ExRumia.png");
		DeleteGraphic(GetCurrentScriptDirectory ~"..img\back1.png");
		DeleteGraphic(GetCurrentScriptDirectory ~"..img\back2.png");
	}
	//XyJ[h̔wi
	//Ă悢
	@BackGround
	{
		BG_Simple;
	}

	task AtackTask{
		wait(120);
		let nway=9;
		loop{
			let dir=GetAngleToPlayer-8;
			loop(nway){
				LoopShot(GetX,GetY,2,dir,65535,RED21,20);
				dir+=2;
			}
			wait(wt);

		}
	}

	task LoopShot(	//ʒ[ɏoƔΑɏoe
		x,
		y,
		spd,
		dir,
		ammo,	//[v
		grf,
		delay
	){
		let obj=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,x,y);
		Obj_SetSpeed(obj,spd);
		Obj_SetAngle(obj,dir);
		ObjShot_SetGraphic(obj,grf);
		ObjShot_SetDelay(obj,delay);
		ObjShot_SetBombResist(obj,true);
		while(!Obj_BeDeleted(obj)){

			if(BorderLeft(Obj_GetX(obj),20)==true){
				Obj_SetX(obj,Obj_GetX(obj)+(GetClipMaxX-GetClipMinX+40));
				ammo--;
			}
			if(BorderRight(Obj_GetX(obj),20)==true){
				Obj_SetX(obj,Obj_GetX(obj)-(GetClipMaxX-GetClipMinX+40));
				ammo--;
			}
			if(BorderTop(Obj_GetY(obj),20)==true){
				Obj_SetY(obj,Obj_GetY(obj)+(GetClipMaxY-GetClipMinY+40));
				ammo--;
			}
			if(BorderBottom(Obj_GetY(obj),20)==true){
				Obj_SetY(obj,Obj_GetY(obj)-(GetClipMaxY-GetClipMinY+40));
				ammo--;
			}

			if(ammo==0){break;}
			yield;
		}

	}

	task ControlTask{
		wait(250);
		while(GetEnemyLife>800&&GetTimer>10){yield;}
		wt=110;
		while(GetEnemyLife>600&&GetTimer>10){yield;}
		wt=100;
		while(GetEnemyLife>400&&GetTimer>10){yield;}
		wt=90;
		while(GetEnemyLife>200&&GetTimer>10){yield;}
		wt=80;
		while(GetTimer>10){yield;}
		wt=70;
	}

	#include_function".\function.txt"
}

